<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <title>去重工具</title>
    <link rel="stylesheet" href="./reset.css">
    <style>
        * {
            padding: 0;
            margin: 0;
            box-sizing: border-box;
        }

        .container {
            height: 100vh;
            padding: 30px;
            justify-content: space-around;
            align-items: center;
        }

        textarea {
            width: 45%;
            height: 90%;
        }

        button {
            width: 100px;
            height: 40px;
            display: block;
            justify-content: center;
            align-items: center;
        }
    </style>
</head>

<body>
    <div class="container flex">
        <textarea id="inputText" rows="10" cols="50"></textarea>
        <button onclick="removeDuplicatesAndEmptyLines()">去重</button>
        <textarea id="outputText" rows="10" cols="50" readonly></textarea>
    </div>


    <script>
        function removeDuplicatesAndEmptyLines() {
            // 获取用户输入的文本
            const inputText = document.getElementById('inputText').value;

            // 使用换行符分割输入文本为数组
            const lines = inputText.split('\n').map(line => line.trim());

            // 去除空行和重复行，同时保持原始顺序
            const uniqueNonEmptyLines = Array.from(new Set(lines.filter(line => line.trim() !== '')));

            // 将处理后的内容显示在输出框
            document.getElementById('outputText').value = uniqueNonEmptyLines.join('\n');
        }
    </script>
</body>

</html>